<?php
//$_GET['id'] 节点编号

	include 'include/function.php';
	
	$showquestion_id=-1;
	if(isset($_GET['id']))$showquestion_id=get_to_mysql($_GET['id']);
	
function draw_questions($condition,$perm) { //condition='where .. '
	$query='select question_id,question,edit_time,level from question ' . $condition;
	$ret=oj_query($query);
	while($row=mysql_fetch_assoc($ret)) {
		echo '<tr>';
			echo "<td>{$row['question_id']}</td>";
			echo "<td>{$row['level']}</td>";
			echo "<td>{$row['edit_time']}</td>";
			echo "<td>{$row['question']}</td>";
			echo '<td>';
				if(strstr($perm,$row['level'])) {
					if(strstr($perm,'modify')) {
						echo "<a href='editquestion.php?qid={$row['question_id']}'>" . _d('sn_edit') . '</a>&nbsp;';
					}
					if(strstr($perm,'delete')) {
						echo "<a href='deletequestion.php?qid={$row['question_id']}&confirm=1'>Delete</a>&nbsp;";
					}
				}
			echo '</td>';
		echo '</tr>';
	}
}

	include 'include/header.php';
	echo "<title>$site_title - Questions</title>";
	
	//echo "<center><h2><a href='shownode.php?id=$showquestion_id'>Node-$showquestion_id</a></h2></center>";
	draw_parents($showquestion_id);
	echo 'Questions<br>';
	$showquestion_perm=permission_node($_user_id,$showquestion_id);
	if(isset($showquestion_perm[0])) {
		draw_tablelist_head(array('Question ID','Level',_d('n_edit'),array('Question','width=60%'),'Action'));
			draw_questions("where node_id=$showquestion_id order by level asc ",$showquestion_perm[0]);
			if(strstr($showquestion_perm[0],'add')){
				echo '<tr><td colspan=5>';
					echo "<a href='addquestion.php?id=$showquestion_id'>Add new</a>";
				echo '</td></tr>';
			}
		echo '</table>';
	}

	include 'include/footer.php';
?>

